package com.guchenbo.springboot;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @author guchenbo
 * @date 2022/6/27
 */
@Configuration
@EnableWebSocket
public class DemoWebSocketConfigurer implements WebSocketConfigurer {
    @Resource
    private DemoWebSocketHandler demoWebSocketHandler;
    @Resource
    private DemoHandshakeInterceptor demoHandshakeInterceptor;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(demoWebSocketHandler, "ws").addInterceptors(demoHandshakeInterceptor);
    }
}
